package com.ycz.pattern.create.factorypattern;

/**
 * @Description 工厂类，返回接口对象
 * @ClassName ShapeFactory
 * @Author yanchengzhi
 * @date 2023.11.14 23:28
 */
public class ShapeFactory {

    public Shape getShape(String type) {
        if(type == null) return null;
        if("circle".equalsIgnoreCase(type)) {
            return new Circle();
        } else if("rectangle".equalsIgnoreCase(type)) {
            return new Rectangle();
        } else if("square".equalsIgnoreCase(type)) {
            return new Square();
        }
        return null;
    }

}
